<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html>
<head>
{include file='header.tpl' JS=$smarty.const.BAOGG_JS CSS=$smarty.const.BAOGG_CSS}        
        
        <script type="text/javascript"> 
          var form_url='{$form_url}';
	var  LANG={$LANG};
	{literal}
Ext.onReady(function(){

	
                
                
                var form = new Ext.FormPanel({
                    url: form_url,
                    region: 'north',
                    el: "form",
                    frame: true,
		    bodyBorder :false,
                    bodyStyle: 'padding:15px 15px 0;',
                    height: 250,
                    items: [{
                        layout: 'column',
                        
                        items: [{/literal}{$json_field_items}{literal}]
                    }],
                    
                    buttons: [{
                        text: LANG.save,
			handler :function(b,e){
				form.getForm().submit({
				    clientValidation: true,				  
				  
				    success: function(form, action) {					
				       top.Ext.example.msg(LANG.save_ok, action.result.msg);
				       grid.getStore().load()					
				    },
				    failure: function(form, action) {
					switch (action.failureType) {
					    case Ext.form.Action.CLIENT_INVALID:
						top.Ext.example.msg(LANG.failure, "Form fields may not be submitted with invalid values");
						break;
					    case Ext.form.Action.CONNECT_FAILURE:
						top.Ext.example.msg(LANG.failure, "Ajax communication failed");
						break;
					    case Ext.form.Action.SERVER_INVALID:
					       top.Ext.example.msg(LANG.failure, action.result.msg);
					       break;
					    default:
					      top.Ext.example.msg(LANG.failure, action.result.msg);
					      break;
				       }
				    }
				});
			}
                    }, {
                        text: LANG.search,
			handler:function(b,e){
				grid.getStore().load(Ext.apply(grid.getStore().baseParams,form.getForm().getValues()));
			}
                    }, {
                        text: LANG.reset,
			handler:function(b,e){form.getForm().reset();}
                    }]
                });
{/literal}
	{$grid}
{literal}
		


	 Ext.create('Ext.container.Viewport', {
    layout: 'border',
    renderTo: Ext.getBody(),
                    items: grid				
                });
		win_form.show().center().hide();

});
</script>
{/literal}
 
</head>
<body>
  
       
<div id="form"></div>
<div id="grid"></div>


</body>
</html>